package me.sunpeng.design.singleton.type3;

/**
 * @author sp
 */
public class SingletonTest03 {
    public static void main(String[] args) {

    }

}

class Singleton {
    private static Singleton instance;

    private Singleton() {

    }

    //提供一个静态的共有方法，当使用到该方法时，才去创建intance
    //即懒汉式
    public static Singleton getInstance() {
        if (instance == null) {
            return new Singleton();
        }
        return instance;
    }
}